home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-04-10 | 2.7 KB | 136 lines | [TEXT/MPS ] |
- /*-----------------------------------------------------------------------------
-
- Generic LaserWriter.c
-
- This part of the driver demonstrates how to force the PostScript
- imaging system to copy its output to a file.
-
- 12/18/93 - dmh - Removed IIg-dependencies for b3.
- 9/13/93 - dmh - Updated for the b2 seed.
- 9/14/93 - dmh - Disabled the PostScript log which was created in
- the Extensions folder.
- 3/22/94 - dmh - Balanced gxInitialize override with a gxShutDown one.
-
- © 1991-1994 Apple Computer Inc.
-
- -----------------------------------------------------------------------------*/
-
- // If non-zero, we create a PostScript log in the Extensions folder.
-
- #define CREATELOG 0
-
- #include <PrintingDrivers.h>
- #include <GXExceptions.h>
-
- extern long A5Size (void);
- extern void A5Init (void *);
-
-
- // Globals...
-
- short gLogRefNum;
-
-
- OSErr DriverPostScriptDoPageSetup( gxFormat theFormat,
- long pageindx,
- gxPostScriptImageDataHdl imageDataHdl )
- {
- OSErr status;
- char *setupcommand = "\p%% File For Level-I or Level-II.\n";
-
- require(CREATELOG, Not_Logging);
- status = Send_GXBufferData( & setupcommand[ 1 ], setupcommand[ 0 ], nil );
- nrequire( status, BufferCommandFailed );
-
- Not_Logging:
-
- status = Forward_GXPostScriptDoPageSetup( theFormat, pageindx, imageDataHdl );
- ncheck( status );
-
- BufferCommandFailed:
- return( status );
- }
-
-
-
- OSErr DriverOpenConnection(void)
- {
- OSErr status;
-
- status = Forward_GXOpenConnection();
- nrequire(status, failed_Forward);
- require(CREATELOG, Not_Logging);
-
- status = Create("\pPostScriptLog.ps", 0, 'MPS ', 'TEXT');
- ncheck(status);
- status = FSOpen("\pPostScriptLog.ps", 0, &gLogRefNum);
- ncheck(status);
-
- status = noErr;
-
- Not_Logging:
- failed_Forward:
- return(status);
-
- }//DriverOpenConnection
-
-
- OSErr DriverCloseConnection(void)
- {
- OSErr status;
- long j;
-
- status = Forward_GXCloseConnection();
- nrequire(status, failed_Forward);
- require(CREATELOG, Not_Logging);
-
- GetFPos(gLogRefNum, &j);
- SetEOF(gLogRefNum, j);
- FSClose(gLogRefNum);
-
- Not_Logging:
- failed_Forward:
- return(status);
- }
-
-
-
- OSErr DriverInitialize(void)
- {
- OSErr status;
-
- status = NewMessageGlobals(A5Size(), A5Init);
- nrequire(status, failed_a5);
-
- failed_a5:
- return(status);
-
- }
-
-
- OSErr DriverShutDown(void)
- {
- DisposeMessageGlobals();
- return noErr;
- }
-
-
- OSErr DriverDumpBuffer(gxPrintingBuffer *buffPtr)
- {
- OSErr status;
- long count;
-
- require(CREATELOG, Not_Logging);
- count = buffPtr->size;
-
- status = FSWrite(gLogRefNum, &count, buffPtr->data);
- nrequire(status, failed_Write);
-
- Not_Logging:
- status = Forward_GXDumpBuffer(buffPtr);
- ncheck(status);
-
- failed_Write:
- return(status);
-
- }